﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace dnf_speed_shoe
{
    public partial class 攻速鞋计算器 : Form
    {
        public 攻速鞋计算器()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private int get_int_num(string number, string name)
        {
            int outnum = 0;
            if (number.Contains("."))
            {
                MessageBox.Show($"请不要输入小数!(单元格：{name})");
                return -1;
            }
            number = System.Text.RegularExpressions.Regex.Replace(number, @"[^0-9]+", "");
            bool res = int.TryParse(number, out outnum);
            if (res)
            {
                return outnum;
            }
            else
            {
                MessageBox.Show($"{name}值输入非法,请输入包含整数数字的文字！");
                return -1;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int total_speed = 0;
            ArrayList list = new ArrayList();
            int 称号 = get_int_num(comboBox1.Text, "称号");
            int 头肩 = get_int_num(textBox1.Text, "头肩");
            int 上衣 = get_int_num(textBox2.Text, "上衣");
            int 下装 = get_int_num(textBox3.Text, "下装");
            int 腰带 = get_int_num(textBox4.Text, "腰带");
            int 鞋子 = get_int_num(textBox5.Text, "鞋子");
            int 手镯 = get_int_num(textBox6.Text, "手镯");
            int 项链 = get_int_num(textBox7.Text, "项链");
            int 戒指 = get_int_num(textBox8.Text, "戒指");
            int 耳环 = get_int_num(textBox9.Text, "耳环");
            int 右槽 = get_int_num(textBox10.Text, "右槽");
            int 左槽 = get_int_num(textBox11.Text, "左槽");
            int 武器装扮 = get_int_num(comboBox2.Text, "武器装扮");
            int 徽章 = get_int_num(textBox12.Text, "徽章");
            int 守护珠 = get_int_num(textBox13.Text, "守护珠");
            int 宠物装备 = get_int_num(textBox14.Text, "宠物装备");
            int 宠物 = get_int_num(textBox15.Text, "宠物");
            int 光环 = get_int_num(textBox16.Text, "光环");
            int 时装 = get_int_num(comboBox3.Text, "时装");
            int 贴膜 = get_int_num(textBox18.Text, "贴膜");
            int 快捷栏装备 = get_int_num(textBox19.Text, "快捷栏装备");
            list.Add(称号);
            list.Add(头肩);
            list.Add(上衣);
            list.Add(下装);
            list.Add(腰带);
            list.Add(鞋子);
            list.Add(手镯);
            list.Add(项链);
            list.Add(戒指);
            list.Add(耳环);
            list.Add(右槽);
            list.Add(左槽);
            list.Add(武器装扮);
            list.Add(徽章);
            list.Add(守护珠);
            list.Add(宠物装备);
            list.Add(宠物);
            list.Add(光环);
            list.Add(时装);
            list.Add(贴膜);
            list.Add(快捷栏装备);
            foreach (var item in list)
            {
                if ((int)item==-1)
                {
                    return;
                }
                else
                {
                    total_speed += (int)item;
                }
            }
            textBox20.Text = total_speed.ToString();
            int 技攻 = 0;
            if (total_speed>=100 && total_speed<120)
            {
                技攻 = 10;
            }
            else if (total_speed >= 120 && total_speed < 140)
            {
                技攻 = 20;
            }
            else if (total_speed>=140)
            {
                技攻 = 30;
            }
            textBox17.Text = 技攻.ToString();
        }
    }
}
